this.BX=this.BX||{};this.BX.UI=this.BX.UI||{};this.BX.UI.FileUploader=this.BX.UI.FileUploader||{};(function(t,e,i,r,a,s,l,o,n,d){"use strict";var u=s.BitrixVue.localComponent("drop-area",{mounted:function t(){var e=this.$Bitrix.Application.get();e.getUploader().assignDropzone(this.$refs.dropArea);e.getUploader().assignBrowse(this.$refs.dropArea)},template:'\n\t\t<div class="disk-file-control-panel" ref="dropArea">\n\t\t\t<div class="disk-file-control-panel-btn-upload-box">\n\t\t\t\t<label class="disk-file-control-panel-btn-upload">Drag and Drop</label>\n\t\t\t\t<div class="disk-file-control-panel-btn-settings"></div>\n\t\t\t</div>\n\t\t</div>\n\t'});var p=s.BitrixVue.component("tile-uploader.uploader-loader",{mounted:function t(){this.createProgressbar()},beforeDestroy:function t(){this.removeProgressbar()},props:{progress:{type:Number,default:0},item:{type:Object,default:{}}},methods:{createProgressbar:function t(){this.loader=new r.ProgressRound({width:20,colorTrack:"#73d8f8",colorBar:"#fff",lineSize:3,rotation:true,color:r.ProgressRound.Color.SUCCESS});this.loader.renderTo(this.$refs.container)},updateProgressbar:function t(){if(this.item.status!=="uploading"){return}if(!this.loader){this.createProgressbar()}this.loader.update(this.item.progress?this.item.progress:0)},removeProgressbar:function t(){if(this.loader){l.Dom.remove(this.loader.getContainer());this.loader=null}}},computed:{uploadProgress:function t(){return String(this.item.progress)}},watch:{uploadProgress:function t(){this.updateProgressbar()}},template:'<div class="ui-tile-uploader-item-loader" ref="container"></div>'});var c=s.BitrixVue.localComponent("tile",{props:{item:{type:Object,default:{}}},components:{UploadLoader:p},data:function t(){return{tileId:"tile-uploader-"+l.Text.getRandom().toLowerCase(),menu:null,errorPopup:null}},methods:{remove:function t(e){var i=this.$Bitrix.Application.get();i.remove(e)},handleMouseEnter:function t(e){if(e.error){if(!this.errorPopup){this.errorPopup=new o.Popup({bindElement:this.$refs.container,darkMode:true,animation:"fading-slide",width:250,angle:{offset:110},offsetTop:6,offsetLeft:-25,content:e.error.getMessage()+"<br>"+e.error.getDescription()})}this.errorPopup.show()}},handleMouseLeave:function t(){if(this.errorPopup){this.errorPopup.destroy();this.errorPopup=null}},showMenu:function t(e){if(this.menu){this.menu.destroy()}this.menu=o.MenuManager.create({id:this.tileId,bindElement:this.$refs.menu,cacheable:false,items:[{text:"Download",href:e.downloadUrl}]});this.menu.show()}},computed:{FileStatus:function t(){return i.FileStatus},status:function t(){if(this.item.status===i.FileStatus.UPLOADING){return this.item.progress+"%"}else if(this.item.status===i.FileStatus.LOAD_FAILED||this.item.status===i.FileStatus.UPLOAD_FAILED){return l.Loc.getMessage("TILE_UPLOADER_ERROR_STATUS")}else{return l.Loc.getMessage("TILE_UPLOADER_WAITING_STATUS")}}},template:'\n\t\t<div\n\t\t\tclass="ui-tile-uploader-item"\n\t\t\t:class="[\'ui-tile-uploader-item--\' + item.status]"\n\t\t\t@mouseenter="handleMouseEnter(item)"\n\t\t\t@mouseleave="handleMouseLeave(item)"\n\t\t\tref="container"\n\t\t>\n\t\t\t<div class="ui-tile-uploader-item-content">\n\t\t\t\t<div v-if="item.status !== FileStatus.COMPLETE" key="loader" class="ui-tile-uploader-item-state">\n\t\t\t\t\t<UploadLoader v-if="item.status === FileStatus.UPLOADING" :item="item"></UploadLoader>\n\t\t\t\t\t<div v-else class="ui-tile-uploader-item-state-icon"></div>\n\n\t\t\t\t\t<div class="ui-tile-uploader-item-status">{{status}}</div>\n\t\t\t\t\t<div class="ui-tile-uploader-item-state-desc">{{item.sizeFormatted}}</div>\n\t\t\t\t\t<div class="ui-tile-uploader-item-state-remove" @click="remove(item.id)"></div>\n\t\t\t\t</div>\n\t\t\t\t<div v-else key="complete" class="ui-tile-uploader-item-actions">\n\t\t\t\t\t<div class="ui-tile-uploader-item-remove" @click="remove(item.id)"></div>\n\t\t\t\t\t<div class="ui-tile-uploader-item-menu" @click="showMenu(item)" ref="menu"></div>\n\t\t\t\t</div>\n\t\t\t\t<div class="ui-tile-uploader-item-preview">\n\t\t\t\t\t<template v-if="item.isImage">\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclass="ui-tile-uploader-item-image"\n\t\t\t\t\t\t\t:class="{ \'ui-tile-uploader-item-image-default\': item.previewUrl === null }"\n\t\t\t\t\t\t\t:style="{ backgroundImage: item.previewUrl !== null ? \'url(\' + item.previewUrl + \')\' : \'\' }">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="ui-tile-uploader-item-image-name" :title="item.originalName">{{item.originalName}}</div>\n\t\t\t\t\t</template>\n\t\t\t\t\t<div v-else class="ui-tile-uploader-item-file"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t'});var m=s.BitrixVue.localComponent("tile-list",{props:{items:{type:Array,default:[]}},components:{TileItem:c},template:'\n\t\t<div class="ui-tile-uploader-items">\n\t\t\t<TileItem v-for="item in items" :key="item.id" :item="item" />\n\t\t</div>\n\t'});var v=s.BitrixVue.component("tile-uploader.stack",{mounted:function t(){var e=this.$Bitrix.Application.get();e.getUploader().assignDropzone(this.$refs.container)},template:'<div class="ui-tile-uploader-stack" v-on:click="$emit(\'click\')" ref="container">Stack</div>'});var h=s.BitrixVue.localComponent("tile-uploader",{props:{error:{type:Object},stackMode:{type:Boolean,default:false},items:{type:Array,default:[]}},data:function t(){return{popup:null,popupContentId:""}},components:{DropArea:u,TileList:m,Stack:v,MountingPortal:n.MountingPortal},methods:{showPopup:function t(){var e=this;if(!this.popup){var i="stack-uploader-"+l.Text.getRandom().toLowerCase();var r=new o.Popup({width:750,height:400,draggable:true,titleBar:"Uploaded Files",content:'<div id="'.concat(i,'"></div>'),cacheable:false,closeIcon:true,closeByEsc:true,events:{onDestroy:function t(){return e.popup=null}},buttons:[new d.CloseButton({onclick:function t(){return e.popup.close()}})]});this.popupContentId="#".concat(i);this.popup=r}this.popup.show()}},watch:{error:function t(){alert(this.error.message)}},template:'\n\t\t<div class="ui-tile-uploader">\n\t\t\t{{ error && error.message ? error.message : \'none\' }}\n\t\t\t<template v-if="stackMode">\n\t\t\t\t<Stack v-on:click="showPopup"/>\n\t\t\t\t<mounting-portal v-if="popup" :mount-to="popupContentId" append>\n\t\t\t\t\t<TileList :items="items"></TileList>\n\t\t\t\t</mounting-portal>\n\t\t\t</template>\n\t\t\t<template v-else>\n\t\t\t\t<template v-if="items.length === 0">\n\t\t\t\t\t<DropArea />\n\t\t\t\t</template>\n\t\t\t\t<template v-else>\n\t\t\t\t\t<TileList :items="items"></TileList>\n\t\t\t\t\t<DropArea />\n\t\t\t\t</template>\n\t\t\t</template>\n\t\t</div>\n\t'});var f=new WeakMap;var g=new WeakMap;var b=new WeakMap;var F=new WeakMap;var P=new WeakMap;var k=new WeakMap;var U=function(){function t(e,r){var a=this;babelHelpers.classCallCheck(this,t);f.set(this,{writable:true,value:null});g.set(this,{writable:true,value:null});b.set(this,{writable:true,value:[]});F.set(this,{writable:true,value:{}});P.set(this,{writable:true,value:i.UploaderStatus.STOPPED});k.set(this,{writable:true,value:false});var o=l.Type.isPlainObject(r)?Object.assign({},r):{};babelHelpers.classPrivateFieldSet(this,k,o.stackMode===true);var n=this;babelHelpers.classPrivateFieldSet(this,g,s.BitrixVue.createApp({data:function t(){return{items:babelHelpers.classPrivateFieldGet(a,b),stackMode:babelHelpers.classPrivateFieldGet(a,k),error:babelHelpers.classPrivateFieldGet(a,F)}},components:{TileUploaderComponent:h},beforeCreate:function t(){this.$bitrix.Application.set(n)},template:'<TileUploaderComponent :items="items" :stackMode="stackMode" :error="error" />'}));var d=l.Type.isPlainObject(e)?Object.assign({},e):{};var u=d.events;d.events={"File:onAddStart":this.handleFileAdd.bind(this),"File:onRemove":this.handleFileRemove.bind(this),"File:onUploadProgress":this.handleFileUploadProgress.bind(this),"File:onStateChange":this.handleFileStateChange.bind(this),"File:onError":this.handleFileError.bind(this),onError:this.handleError.bind(this)};babelHelpers.classPrivateFieldSet(this,f,new i.Uploader(d));babelHelpers.classPrivateFieldGet(this,f).subscribeFromOptions(u)}babelHelpers.createClass(t,[{key:"getUploader",value:function t(){return babelHelpers.classPrivateFieldGet(this,f)}},{key:"renderTo",value:function t(e){if(l.Type.isDomNode(e)){var i=l.Dom.create("div");e.appendChild(i);if(!this.getUploader().getHiddenFieldsContainer()){this.getUploader().setHiddenFieldsContainer(e)}babelHelpers.classPrivateFieldGet(this,g).mount(i)}}},{key:"remove",value:function t(e){this.getUploader().removeFile(e)}},{key:"getItem",value:function t(e){return babelHelpers.classPrivateFieldGet(this,b).find((function(t){return t.id===e}))}},{key:"createItemFromFile",value:function t(e){var i=e.getState();i.progress=0;return i}},{key:"handleFileAdd",value:function t(e){var i=e.getData(),r=i.file,a=i.error;babelHelpers.classPrivateFieldGet(this,b).push(this.createItemFromFile(r))}},{key:"handleFileError",value:function t(e){var i=e.getData(),r=i.file,a=i.error;var s=this.getItem(r.getId());s.error=a}},{key:"handleFileRemove",value:function t(e){var i=e.getData(),r=i.file;var a=babelHelpers.classPrivateFieldGet(this,b).findIndex((function(t){return t.id===r.getId()}));if(a>=0){babelHelpers.classPrivateFieldGet(this,b).splice(a,1)}}},{key:"handleFileUploadProgress",value:function t(e){var i=e.getData(),r=i.file,a=i.progress;var s=this.getItem(r.getId());if(s){s.progress=a}}},{key:"handleFileStateChange",value:function t(e){var i=e.getData(),r=i.file;var a=this.getItem(r.getId());if(a){Object.assign(a,r.getState())}}},{key:"handleError",value:function t(e){Object.assign(babelHelpers.classPrivateFieldGet(this,F),e.getData().error.toJSON())}}]);return t}();var I=function(t){babelHelpers.inherits(e,t);function e(t,i){var r;babelHelpers.classCallCheck(this,e);r=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(e).call(this,t,i));r.getVue().setTemplate("");return r}return e}(U);t.TileUploader=U})(this.BX.UI.FileUploader.Widgets=this.BX.UI.FileUploader.Widgets||{},BX.Event,BX.UI.FileUploader,BX.UI,BX.UI.FileUploader.Widgets,BX,BX,BX.Main,BX.Vue,BX.UI);
//# sourceMappingURL=ui.tile-uploader.widget.bundle.map.js